package com.campuscrowdsourcing.server.common.expection;

import com.campuscrowdsourcing.server.common.constant.HttpStatus;
import lombok.Getter;

/**
 * 自定义业务异常
 *
 * @author XinYuan Zhao
 * @since 2023/3/9
 */

@Getter
public class ServiceException extends RuntimeException {
    private Integer code;
    private String msg;

    public ServiceException() {
        super();
        this.code = HttpStatus.ERROR;
        this.msg = "错误请求";
    }

    public ServiceException(String msg) {
        super(msg);
        this.code = HttpStatus.ERROR;
        this.msg = msg;
    }


    public ServiceException(Integer code, String msg) {
        super(msg);
        this.code = code;
        this.msg = msg;
    }

    public ServiceException(Integer code, String msg, Throwable cause) {
        super(msg, cause);
        this.code = code;
        this.msg = msg;
    }

    public String getMsg() {
        return msg;
    }

    public Integer getCode() {
        return code;
    }
}